<template>

	<div>
		<div v-if="newList.length != 0">
			<scroller lock-x @on-scroll-bottom="onScrollBottom" ref="scrollerBottom" :scroll-bottom-offst="0">

				<div>

					<div>
						<div style="padding: 0.6rem;border-bottom: solid 1px #7b7b7b;" v-for="(item,index) in newList">

							<div style="font-size: 0.85rem; color: #7b7b7b">{{item.store_id}}</div>
							<div class="flex-row" style="justify-content: space-between;margin-top: 0.3rem">
								<div>{{item.order_id}}</div>
								<div style="color: #fd9a13">-{{item.integral}}</div>
							</div>
							<div style="font-size: 0.8rem;margin-top: 0.3rem; color: #7b7b7b">{{item.addtime}}</div>

						</div>
					</div>
					<load-more tip="loading" v-if="loading"></load-more>

				</div>

			</scroller>

		</div>
		<div v-if="newList.length == 0" style="margin: 1rem auto; width: 50%; text-align: center; color:#7b7a7a ">暂无更多内容！</div>
	</div>

</template>

<script>
	
	import  {base64,DatetimeView,PopupPicker,XButton,Scroller,LoadMore} from 'vux'
	
	export default {

		components: {
			
      PopupPicker,XButton,DatetimeView,Scroller,LoadMore,base64
      
		},
		data() {
			return {

				none: true,
				list: '',
				access_token: '',
				
				onFetching: false,
        loading:false,
        newList:[],
        page:1

			}
		},
		methods: {

			//获取详情
			getDetail() {

				this.$store.commit('updateLoadingStatus', true);

				this.$http.get(this.$store.state.api + 'userdd/integral&access_token=' + this.access_token + '&page=' + this.page)
					.then((response) => {

						console.log(response)

						if(response.body.code == 0) {

							this.list = response.body.data.list
							
							for(var i = 0 ; i < response.body.data.list.length ; i ++){
						
								this.newList.push(this.list[i])
								
							}

						} else {

						}

						this.$store.commit('updateLoadingStatus', false);

					}, (response) => {

					});
			},
			
			//获取地址栏信息
		getUrlStr(name){
	      let reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)","i");
	      if(reg.test(window.location.href)){
	        return unescape(RegExp.$2.replace(/\+/g," "))
	      }
	      return undefined
	    },	
		},

		mounted() {

			var access_token = this.getUrlStr('access_token');
           var parentId = this.getUrlStr('parent_id');
           
            if(parentId == undefined){
              parentId = 0;
           }
           
           var uid = this.getUrlStr('uid');
           
           if(parentId.toString().indexOf('?') > 0){
           	 parentId = parentId.split('?')[0];
           }
           
           var locurl = location.href;
           locurl = base64.encode(locurl.split('?')[0]);
           
       
           if(access_token != undefined){
         
              localStorage.setItem("access_token",access_token); 
              localStorage.setItem("parent_id",this.getUrlStr('uid'));


           }
           
            if(localStorage.getItem('access_token') != null){
         
              this.$root.registerjudge();
              this.$root.getShare();
              
            }else{
            	
        	  this.$root.gotoWechat(locurl,parentId);
            }
           
    	   this.access_token = localStorage.getItem('access_token');

			this.getDetail();

		}

	}
</script>

<style lang="less" scoped>

</style>